﻿package app{

	import flash.events.TouchEvent;
	import flash.events.TUIO;

	import flash.display.*;
	import flash.net.URLRequest;
	import flash.events.Event;
	import flash.text.TextField;

	public class KeyboardDemo extends MovieClip {
		public var newKeyboard:MovieClip=new MovieClip  ;
		public var anyTextField:TextField=new TextField  ;// connects TextField on Stage to this AS Script

		public function KeyboardDemo() {
			TUIO.init(this,'127.0.0.1',3000,'',true);

			var request:URLRequest=new URLRequest("SmallKeyboard.swf");// loads Keyboard into Flash
			var loader:Loader=new Loader  ;
			loader.contentLoaderInfo.addEventListener(Event.COMPLETE,completeHandler);
			loader.load(request);

		}

		private function completeHandler(loadEvent:Event):void {
			trace("completeHandler: "+loadEvent);
			addChild(loadEvent.currentTarget.content);
			var newObj:Object=loadEvent.currentTarget.content;
			trace(newObj);
			newObj.x=300;
			newObj.y=100;
			newObj.attachedTextField=anyTextField;

		}


	}
}